package com.cc.com.cc.atomikos;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
public class TestController {

	@Autowired
	private JdbcTemplate sysJdbcTemplate;

	@Autowired
	private JdbcTemplate busJdbcTemplate;

	@Transactional
	@ResponseBody
	@RequestMapping("")
	public String test() {
		System.out.println("begin.....");
		sysJdbcTemplate.execute("insert into t_test(name) values('chen')");
		int a = 1/0;
		busJdbcTemplate.execute("insert into t_test(name) values('sheng')");
		System.out.println("end.....");
		return "success";
	}
}
